home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / content / nsIDocumentObserver.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  27KB  |  510 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37. #ifndef nsIDocumentObserver_h___
  38. #define nsIDocumentObserver_h___
  39.  
  40. #include "nsISupports.h"
  41.  
  42. class nsIAtom;
  43. class nsIContent;
  44. class nsIPresShell;
  45. class nsIStyleSheet;
  46. class nsIStyleRule;
  47. class nsString;
  48. class nsIDocument;
  49.  
  50. #define NS_IDOCUMENT_OBSERVER_IID \
  51. { 0xb3f92460, 0x944c, 0x11d1, {0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
  52.  
  53. typedef PRUint32 nsUpdateType;
  54.  
  55. #define UPDATE_CONTENT_MODEL 0x00000001
  56. #define UPDATE_STYLE         0x00000002
  57. #define UPDATE_CONTENT_STATE 0x00000004
  58. #define UPDATE_ALL (UPDATE_CONTENT_MODEL | UPDATE_STYLE | UPDATE_CONTENT_STATE)
  59.  
  60. // Document observer interface
  61. class nsIDocumentObserver : public nsISupports
  62. {
  63. public:
  64.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID)
  65.  
  66.   /**
  67.    * Notify that a content model update is beginning. This call can be
  68.    * nested.
  69.    */
  70.   virtual void BeginUpdate(nsIDocument *aDocument,
  71.                            nsUpdateType aUpdateType) = 0;
  72.  
  73.   /**
  74.    * Notify that a content model update is finished. This call can be
  75.    * nested.
  76.    */
  77.   virtual void EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
  78.  
  79.   /**
  80.    * Notify the observer that a document load is beginning.
  81.    */
  82.   virtual void BeginLoad(nsIDocument *aDocument) = 0;
  83.  
  84.   /**
  85.    * Notify the observer that a document load has finished. Note that
  86.    * the associated reflow of the document will be done <b>before</b>
  87.    * EndLoad is invoked, not after.
  88.    */
  89.   virtual void EndLoad(nsIDocument *aDocument) = 0;
  90.  
  91.   /**
  92.    * Notify the observer that the document is being reflowed in
  93.    * the given presentation shell.
  94.    */
  95.   virtual void BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
  96.  
  97.   /**
  98.    * Notify the observer that the document is done being reflowed in
  99.    * the given presentation shell.
  100.    */
  101.   virtual void EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
  102.  
  103.   /**
  104.    * Notification that the content model has changed. This method is
  105.    * called automatically by content objects when their state is changed
  106.    * (therefore there is normally no need to invoke this method
  107.    * directly).  The notification is passed to any
  108.    * IDocumentObservers. The notification is passed on to all of the
  109.    * document observers. <p>
  110.    *
  111.    * This notification is not sent when a piece of content is
  112.    * added/removed from the document (the other notifications are used
  113.    * for that).
  114.    *
  115.    * @param aDocument The document being observed
  116.    * @param aContent the piece of content that changed
  117.    * @param aAppend   Whether the change was an append
  118.    */
  119.   virtual void CharacterDataChanged(nsIDocument *aDocument,
  120.                                     nsIContent* aContent,
  121.                                     PRBool aAppend) = 0;
  122.  
  123.   /**
  124.    * Notification that the state of a content node has changed. 
  125.    * (ie: gained or lost focus, became active or hovered over)
  126.    * This method is called automatically by content objects 
  127.    * when their state is changed (therefore there is normally 
  128.    * no need to invoke this method directly).  The notification 
  129.    * is passed to any IDocumentObservers. The notification is 
  130.    * passed on to all of the document observers. <p>
  131.    *
  132.    * This notification is not sent when a piece of content is
  133.    * added/removed from the document or the content itself changed 
  134.    * (the other notifications are used for that).
  135.    *
  136.    * The optional second content node is to allow optimization
  137.    * of the case where state moves from one node to another
  138.    * (as is likely for :focus and :hover)
  139.    *
  140.    * Either content node may be nsnull, but not both
  141.    *
  142.    * @param aDocument The document being observed
  143.    * @param aContent1 the piece of content that changed
  144.    * @param aContent2 optional second piece of content that changed
  145.    */
  146.   virtual void ContentStatesChanged(nsIDocument* aDocument,
  147.                                     nsIContent* aContent1,
  148.                                     nsIContent* aContent2,
  149.                                     PRInt32 aStateMask) = 0;
  150.  
  151.   /**
  152.    * Notification that the content model has changed. This method is called
  153.    * automatically by content objects when an attribute's value has changed
  154.    * (therefore there is normally no need to invoke this method directly). The
  155.    * notification is passed to any IDocumentObservers document observers. <p>
  156.    *
  157.    * @param aDocument The document being observed
  158.    * @param aContent the piece of content whose attribute changed
  159.    * @param aAttribute the atom name of the attribute
  160.    * @param aModType Whether or not the attribute was added, changed, or removed.
  161.    *   The constants are defined in nsIDOMMutationEvent.h.
  162.    */
  163.   virtual void AttributeChanged(nsIDocument *aDocument,
  164.                                 nsIContent*  aContent,
  165.                                 PRInt32      aNameSpaceID,
  166.                                 nsIAtom*     aAttribute,
  167.                                 PRInt32      aModType) = 0;
  168.  
  169.   /**
  170.    * Notifcation that the content model has had data appended to the
  171.    * given content object. This method is called automatically by the
  172.    * content container objects when a new content object is appended to
  173.    * the container (therefore there is normally no need to invoke this
  174.    * method directly). The notification is passed on to all of the
  175.    * document observers.
  176.    *
  177.    * @param aDocument The document being observed
  178.    * @param aContainer the container that had a new child appended
  179.    * @param aNewIndexInContainer the index in the container of the first
  180.    *          new child
  181.    */
  182.   virtual void ContentAppended(nsIDocument *aDocument,
  183.                                nsIContent* aContainer,
  184.                                PRInt32     aNewIndexInContainer) = 0;
  185.  
  186.   /**
  187.    * Notification that content has been inserted. This method is called
  188.    * automatically by the content container objects when a new content
  189.    * object is inserted in the container (therefore there is normally no
  190.    * need to invoke this method directly). The notification is passed on
  191.    * to all of the document observers.
  192.    *
  193.    * @param aDocument The document being observed
  194.    * @param aContainer the container that now contains aChild
  195.    * @param aChild the child that was inserted
  196.    * @param aIndexInContainer the index of the child in the container
  197.    */
  198.   virtual void ContentInserted(nsIDocument *aDocument,
  199.                                nsIContent* aContainer,
  200.                                nsIContent* aChild,
  201.                                PRInt32 aIndexInContainer) = 0;
  202.  
  203.   /**
  204.    * Content has just been removed. This method is called automatically
  205.    * by content container objects when a content object has just been
  206.    * removed from the container (therefore there is normally no need to
  207.    * invoke this method directly). The notification is passed on to all
  208.    * of the document observers.
  209.    *
  210.    * @param aDocument The document being observed
  211.    * @param aContainer the container that had a child removed
  212.    * @param aChild the child that was just removed
  213.    * @param aIndexInContainer the index of the child in the container
  214.    *  before it was removed
  215.    */
  216.   virtual void ContentRemoved(nsIDocument *aDocument,
  217.                               nsIContent* aContainer,
  218.                               nsIContent* aChild,
  219.                               PRInt32 aIndexInContainer) = 0;
  220.  
  221.   /**
  222.    * A StyleSheet has just been added to the document.  This method is
  223.    * called automatically when a StyleSheet gets added to the
  224.    * document, even if the stylesheet is not applicable. The
  225.    * notification is passed on to all of the document observers.   
  226.    *
  227.    * @param aDocument The document being observed
  228.    * @param aStyleSheet the StyleSheet that has been added
  229.    * @param aDocumentSheet True if sheet is in document's style sheet list,
  230.    *                       false if sheet is not (i.e., UA or user sheet)
  231.    */
  232.   virtual void StyleSheetAdded(nsIDocument *aDocument,
  233.                                nsIStyleSheet* aStyleSheet,
  234.                                PRBool aDocumentSheet) = 0;
  235.  
  236.   /**
  237.    * A StyleSheet has just been removed from the document.  This
  238.    * method is called automatically when a StyleSheet gets removed
  239.    * from the document, even if the stylesheet is not applicable. The
  240.    * notification is passed on to all of the document observers.
  241.    *
  242.    * @param aDocument The document being observed
  243.    * @param aStyleSheet the StyleSheet that has been removed
  244.    * @param aDocumentSheet True if sheet is in document's style sheet list,
  245.    *                       false if sheet is not (i.e., UA or user sheet)
  246.    */
  247.   virtual void StyleSheetRemoved(nsIDocument *aDocument,
  248.                                  nsIStyleSheet* aStyleSheet,
  249.                                  PRBool aDocumentSheet) = 0;
  250.   
  251.   /**
  252.    * A StyleSheet has just changed its applicable state.
  253.    * This method is called automatically when the applicable state
  254.    * of a StyleSheet gets changed. The style sheet passes this
  255.    * notification to the document. The notification is passed on 
  256.    * to all of the document observers.
  257.    *
  258.    * @param aDocument The document being observed
  259.    * @param aStyleSheet the StyleSheet that has changed state
  260.    * @param aApplicable PR_TRUE if the sheet is applicable, PR_FALSE if
  261.    *        it is not applicable
  262.    */
  263.   virtual void StyleSheetApplicableStateChanged(nsIDocument *aDocument,
  264.                                                 nsIStyleSheet* aStyleSheet,
  265.                                                 PRBool aApplicable) = 0;
  266.  
  267.   /**
  268.    * A StyleRule has just been modified within a style sheet.
  269.    * This method is called automatically when the rule gets
  270.    * modified. The style sheet passes this notification to 
  271.    * the document. The notification is passed on to all of 
  272.    * the document observers.
  273.    *
  274.    * Since nsIStyleRule objects are immutable, there is a new object
  275.    * replacing the old one.  However, the use of this method (rather
  276.    * than StyleRuleAdded and StyleRuleRemoved) implies that the new rule
  277.    * matches the same elements and has the same priority (weight,
  278.    * origin, specificity) as the old one.  (However, if it is a CSS
  279.    * style rule, there may be a change in whether it has an important
  280.    * rule.)
  281.    *
  282.    * @param aDocument The document being observed
  283.    * @param aStyleSheet the StyleSheet that contians the rule
  284.    * @param aOldStyleRule The rule being removed.  This rule may not be
  285.    *                      fully valid anymore -- however, it can still
  286.    *                      be used for pointer comparison and
  287.    *                      |QueryInterface|.
  288.    * @param aNewStyleRule The rule being added.
  289.    */
  290.   virtual void StyleRuleChanged(nsIDocument *aDocument,
  291.                                 nsIStyleSheet* aStyleSheet,
  292.                                 nsIStyleRule* aOldStyleRule,
  293.                                 nsIStyleRule* aNewStyleRule) = 0;
  294.  
  295.   /**
  296.    * A StyleRule has just been added to a style sheet.
  297.    * This method is called automatically when the rule gets
  298.    * added to the sheet. The style sheet passes this
  299.    * notification to the document. The notification is passed on 
  300.    * to all of the document observers.
  301.    *
  302.    * @param aDocument The document being observed
  303.    * @param aStyleSheet the StyleSheet that has been modified
  304.    * @param aStyleRule the rule that was added
  305.    */
  306.   virtual void StyleRuleAdded(nsIDocument *aDocument,
  307.                               nsIStyleSheet* aStyleSheet,
  308.                               nsIStyleRule* aStyleRule) = 0;
  309.  
  310.   /**
  311.    * A StyleRule has just been removed from a style sheet.
  312.    * This method is called automatically when the rule gets
  313.    * removed from the sheet. The style sheet passes this
  314.    * notification to the document. The notification is passed on 
  315.    * to all of the document observers.
  316.    *
  317.    * @param aDocument The document being observed
  318.    * @param aStyleSheet the StyleSheet that has been modified
  319.    * @param aStyleRule the rule that was removed
  320.    */
  321.   virtual void StyleRuleRemoved(nsIDocument *aDocument,
  322.                                 nsIStyleSheet* aStyleSheet,
  323.                                 nsIStyleRule* aStyleRule) = 0;
  324.  
  325.  /**
  326.    * The document is in the process of being destroyed.
  327.    * This method is called automatically during document
  328.    * destruction.
  329.    * 
  330.    * @param aDocument The document being observed
  331.    */
  332.   virtual void DocumentWillBeDestroyed(nsIDocument *aDocument) = 0;
  333. };
  334.  
  335. #define NS_DECL_NSIDOCUMENTOBSERVER                                          \
  336.     virtual void BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
  337.     virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
  338.     virtual void BeginLoad(nsIDocument* aDocument);                          \
  339.     virtual void EndLoad(nsIDocument* aDocument);                            \
  340.     virtual void BeginReflow(nsIDocument* aDocument,                         \
  341.                              nsIPresShell* aShell);                          \
  342.     virtual void EndReflow(nsIDocument* aDocument,                           \
  343.                            nsIPresShell* aShell);                            \
  344.     virtual void CharacterDataChanged(nsIDocument* aDocument,                \
  345.                                       nsIContent* aContent,                  \
  346.                                       PRBool aAppend);                       \
  347.     virtual void ContentStatesChanged(nsIDocument* aDocument,                \
  348.                                       nsIContent* aContent1,                 \
  349.                                       nsIContent* aContent2,                 \
  350.                                       PRInt32 aStateMask);                   \
  351.     virtual void AttributeChanged(nsIDocument* aDocument,                    \
  352.                                   nsIContent* aContent,                      \
  353.                                   PRInt32 aNameSpaceID,                      \
  354.                                   nsIAtom* aAttribute,                       \
  355.                                   PRInt32 aModType);                         \
  356.     virtual void ContentAppended(nsIDocument* aDocument,                     \
  357.                                  nsIContent* aContainer,                     \
  358.                                  PRInt32 aNewIndexInContainer);              \
  359.     virtual void ContentInserted(nsIDocument* aDocument,                     \
  360.                                  nsIContent* aContainer,                     \
  361.                                  nsIContent* aChild,                         \
  362.                                  PRInt32 aIndexInContainer);                 \
  363.     virtual void ContentRemoved(nsIDocument* aDocument,                      \
  364.                                 nsIContent* aContainer,                      \
  365.                                 nsIContent* aChild,                          \
  366.                                 PRInt32 aIndexInContainer);                  \
  367.     virtual void StyleSheetAdded(nsIDocument* aDocument,                     \
  368.                                  nsIStyleSheet* aStyleSheet,                 \
  369.                                  PRBool aDocumentSheet);                     \
  370.     virtual void StyleSheetRemoved(nsIDocument* aDocument,                   \
  371.                                    nsIStyleSheet* aStyleSheet,               \
  372.                                    PRBool aDocumentSheet);                   \
  373.     virtual void StyleSheetApplicableStateChanged(nsIDocument* aDocument,    \
  374.                                                   nsIStyleSheet* aStyleSheet,\
  375.                                                   PRBool aApplicable);       \
  376.     virtual void StyleRuleChanged(nsIDocument* aDocument,                    \
  377.                                   nsIStyleSheet* aStyleSheet,                \
  378.                                   nsIStyleRule* aOldStyleRule,               \
  379.                                   nsIStyleRule* aNewStyleRule);              \
  380.     virtual void StyleRuleAdded(nsIDocument* aDocument,                      \
  381.                                 nsIStyleSheet* aStyleSheet,                  \
  382.                                 nsIStyleRule* aStyleRule);                   \
  383.     virtual void StyleRuleRemoved(nsIDocument* aDocument,                    \
  384.                                   nsIStyleSheet* aStyleSheet,                \
  385.                                   nsIStyleRule* aStyleRule);                 \
  386.     virtual void DocumentWillBeDestroyed(nsIDocument* aDocument);            \
  387.  
  388.  
  389. #define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class)                     \
  390. void                                                                      \
  391. _class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)     \
  392. {                                                                         \
  393. }                                                                         \
  394. void                                                                      \
  395. _class::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)       \
  396. {                                                                         \
  397. }                                                                         \
  398. void                                                                      \
  399. _class::DocumentWillBeDestroyed(nsIDocument* aDocument)                   \
  400. {                                                                         \
  401. }
  402.  
  403. #define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class)                     \
  404. void                                                                      \
  405. _class::BeginLoad(nsIDocument* aDocument)                                 \
  406. {                                                                         \
  407. }                                                                         \
  408. void                                                                      \
  409. _class::EndLoad(nsIDocument* aDocument)                                   \
  410. {                                                                         \
  411. }
  412.  
  413. #define NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(_class)                   \
  414. void                                                                      \
  415. _class::BeginReflow(nsIDocument* aDocument,                               \
  416.                     nsIPresShell* aShell)                                 \
  417. {                                                                         \
  418. }                                                                         \
  419. void                                                                      \
  420. _class::EndReflow(nsIDocument* aDocument,                                 \
  421.                   nsIPresShell* aShell)                                   \
  422. {                                                                         \
  423. }
  424.  
  425. #define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class)                    \
  426. void                                                                      \
  427. _class::ContentStatesChanged(nsIDocument* aDocument,                      \
  428.                              nsIContent* aContent1,                       \
  429.                              nsIContent* aContent2,                       \
  430.                              PRInt32 aStateMask)                          \
  431. {                                                                         \
  432. }
  433.  
  434. #define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class)                       \
  435. void                                                                      \
  436. _class::CharacterDataChanged(nsIDocument* aDocument,                      \
  437.                              nsIContent* aContent,                        \
  438.                              PRBool aAppend)                              \
  439. {                                                                         \
  440. }                                                                         \
  441. void                                                                      \
  442. _class::AttributeChanged(nsIDocument* aDocument,                          \
  443.                          nsIContent* aContent,                            \
  444.                          PRInt32 aNameSpaceID,                            \
  445.                          nsIAtom* aAttribute,                             \
  446.                          PRInt32 aModType)                                \
  447. {                                                                         \
  448. }                                                                         \
  449. void                                                                      \
  450. _class::ContentAppended(nsIDocument* aDocument,                           \
  451.                         nsIContent* aContainer,                           \
  452.                         PRInt32 aNewIndexInContainer)                     \
  453. {                                                                         \
  454. }                                                                         \
  455. void                                                                      \
  456. _class::ContentInserted(nsIDocument* aDocument,                           \
  457.                         nsIContent* aContainer,                           \
  458.                         nsIContent* aChild,                               \
  459.                         PRInt32 aIndexInContainer)                        \
  460. {                                                                         \
  461. }                                                                         \
  462. void                                                                      \
  463. _class::ContentRemoved(nsIDocument* aDocument,                            \
  464.                        nsIContent* aContainer,                            \
  465.                        nsIContent* aChild,                                \
  466.                        PRInt32 aIndexInContainer)                         \
  467. {                                                                         \
  468. }
  469.  
  470. #define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class)                    \
  471. void                                                                      \
  472. _class::StyleSheetAdded(nsIDocument* aDocument,                           \
  473.                         nsIStyleSheet* aStyleSheet,                       \
  474.                         PRBool aDocumentSheet)                            \
  475. {                                                                         \
  476. }                                                                         \
  477. void                                                                      \
  478. _class::StyleSheetRemoved(nsIDocument* aDocument,                         \
  479.                           nsIStyleSheet* aStyleSheet,                     \
  480.                           PRBool aDocumentSheet)                          \
  481. {                                                                         \
  482. }                                                                         \
  483. void                                                                      \
  484. _class::StyleSheetApplicableStateChanged(nsIDocument* aDocument,          \
  485.                                          nsIStyleSheet* aStyleSheet,      \
  486.                                          PRBool aApplicable)              \
  487. {                                                                         \
  488. }                                                                         \
  489. void                                                                      \
  490. _class::StyleRuleChanged(nsIDocument* aDocument,                          \
  491.                          nsIStyleSheet* aStyleSheet,                      \
  492.                          nsIStyleRule* aOldStyleRule,                     \
  493.                          nsIStyleRule* aNewStyleRule)                     \
  494. {                                                                         \
  495. }                                                                         \
  496. void                                                                      \
  497. _class::StyleRuleAdded(nsIDocument* aDocument,                            \
  498.                        nsIStyleSheet* aStyleSheet,                        \
  499.                        nsIStyleRule* aStyleRule)                          \
  500. {                                                                         \
  501. }                                                                         \
  502. void                                                                      \
  503. _class::StyleRuleRemoved(nsIDocument* aDocument,                          \
  504.                          nsIStyleSheet* aStyleSheet,                      \
  505.                          nsIStyleRule* aStyleRule)                        \
  506. {                                                                         \
  507. }
  508.  
  509. #endif /* nsIDocumentObserver_h___ */
  510.